package com.itheima.feiqiu;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class Demo01 {


    public static void main(String[] args) throws IOException {
            //创建发送对象
            DatagramSocket ds = new DatagramSocket();
            while (true) {
                //组织数据
                byte[] bytes = "1:100:用户名:主机名:32:消息".getBytes("gbk");
                DatagramPacket dp = new DatagramPacket(bytes, bytes.length, InetAddress.getByName("192.168.13.54"), 2425);
                // 发送
                ds.send(dp);
            }
            //释放资源
            //   ds.close();
    }
}
